using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace SharksHunter.UI
{
    public partial class MainForm : Form, SharksHunter.Controller.Interfaces.ICollectionView
    {
        #region MEMBERS
        SharksHunter.Controller.Interfaces.ICollectionPresenter _presenter;
        #endregion

        #region WinGets
        private SharksHunter.TransferObjects.Presentation.IActionButton _saveCollectionBtn;
        private SharksHunter.TransferObjects.Presentation.IActionButton _newCollectionBtn;
        #endregion

        #region CTOR
        public MainForm()
        {
            InitializeComponent();

            _presenter = new SharksHunter.Controller.Presenter.CollectionPresenter(this);
            CreateWinGets();

        }

        private void CreateWinGets()
        {
            _saveCollectionBtn = new SharksHunter.UI.Controls.MenuActionButton(this.saveToolStripMenuItem);
            _saveCollectionBtn.Click += delegate { _presenter.SaveCollection(); };

            _newCollectionBtn = new SharksHunter.UI.Controls.MenuActionButton(this.newToolStripMenuItem);
            _newCollectionBtn.Click += delegate { _presenter.NewCollection(); };
        }


        #endregion

        private void simpleButton1_Click(object sender, EventArgs e)
        {

        }

        private void newToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //this.collectionBindingSource.DataSource = cm.CreateCollection();
        }

        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //cm.SaveCollection();
        }

        private void MainForm_Load(object sender, EventArgs e)
        {
            
        }

        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //this.collectionBindingSource.DataSource = cm.OpenCollection();
        }

        private void addEntityToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if(this.openFileDialog.ShowDialog() == DialogResult.OK)
            {
                foreach(string path in openFileDialog.FileNames)
                {
                }
            }
        }

        private void huntToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //cm.Hunt();
        }

        #region ICollectionView


        public object DataSource
        {
            set
            {
                this.collectionBindingSource.DataSource = value;
            }
        }

        public void Log(SharksHunter.TransferObjects.Presentation.LogPriority pr, string text)
        {
            if(pr == SharksHunter.TransferObjects.Presentation.LogPriority.Critical)
            {
                MessageBox.Show(text);
            }
        }

        #region IActionButton
        public SharksHunter.TransferObjects.Presentation.IActionButton NewActionButton { 
            get{
                return this.NewActionButton;
            }
                }
        //IActionButton OpenActionButton { get;}
        #endregion

        #region Params
        public SharksHunter.TransferObjects.Presentation.IParamProvider QueryNewCollectionParam()
        {
            return new SharksHunter.UI.Controls.NewCollectionParamProvider(new Windows.NewCollection());
        }
        #endregion

        #endregion

    }
}